<html lang='en'>

<head>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
        integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
        crossorigin="anonymous"></script>
    <style>
        .captionpdf {
            font-size: 1.5em;
            text-align: center;
        }
    </style>
</head>

<body>

    <div class='container'>
        <div class='row mt-3 mb-3'>
            <div class='col'>
                <h1 style="text-align:center;">Attention is not Explanation -- Results</h1>
            </div>
        </div>
        <div class='row'>
            <form class='form-inline'>
                <div class="form-group mb-2">
		            <label class="col-form-label" for="dataset">Dataset: </label>
                    <select name="Dataset" id="dataset" class="form-control">
                        <optgroup label="Classification" metric='pr_auc'>
                            <option value="sst">SST</option>
                            <option value="imdb">IMDB</option>
                            <option value="20News_sports">20 NewsGroup</option>
                            <option value="tweet">Adverse Drug Reaction (Twitter)</option>
                            <option value="agnews">AG News</option>
                            <option value="diab">MIMICIII - Diabetes</option>
                            <option value="anemia">MIMICIII - Anemia</option>
                        </optgroup>
                        <optgroup label="Natural Language Inference" metric='accuracy'>
                            <option value="snli">SNLI</option>
                        </optgroup>
                        <optgroup label="Question Answering" metric='accuracy'>
                            <option value="cnn">CNN</option>
                            <option value="babi_1">Babi 1</option>
                            <option value="babi_2">Babi 2</option>
                            <option value="babi_3">Babi 3</option>
                        </optgroup>
                        <optgroup label="EHR Datasets" metric='roc_auc'>
                            <option value="readmission">Readmission</option>
                            <option value="mortality">Mortality 30 day</option>
                            <option value="Phenotyping">Phenotyping</option>
                            <option value="HipSurgery">Hip Surgery Complications</option>
                            <option value="KneeSurgery">Knee Surgery Complications</option>
                        </optgroup>
                    </select>
                </div>
                <div class="form-group mx-sm-3 mb-2">
                    <label class="col-form-label" for="experiment">Experiment: </label>
                    <select name="Experiment" id="experiment" class="form-control">
                        <optgroup label="Feature Importance Correlation">
                            <option value="GradientXHist_kendalltau">Gradients (Kendall Tau)</option>
                            <option value="pyxc-pyc_SP_kendalltau">Leave One Out (Kendall Tau)</option>
                            <option value="GradientLOOHist_kendalltau">Correlations (Kendall Tau)</option>
                            
                            <!-- <option value="GradientXHist_kendalltop">Gradients (Kendall Top K)</option>
                            <option value="pyxc-pyc_SP_kendalltop">Leave One Out (Kendall Top K)</option>
                            <option value="GradientLOOHist_kendalltop">Correlations (Kendall Top K)</option> -->
                        </optgroup>
                        <optgroup label="Permutation">
                            <option value="Permutation_MAvDY">Permutation Scatterplots</option>
                        </optgroup>
                        <optgroup label="Adversarial Attention">
                            <option value="eMaxJDS_Hist">Adversarial Histogram</option>
                            <option value="eMaxJDS_Scatter">Adversarial Scatterplots</option>
                        </optgroup>
                    </select>
                    
                </div>
                <button type='button' class="btn btn-primary mb-2" id="submitform">Submit</button>
            </form>
        </div>
        <div class='row'>
            <div class="col" width="100%" height="100%">
                <figure class="figure">
                    <!-- <canvas id="pdfaveragetanh"></canvas> -->
                    <object id="svgaveragetanh" data="" type="image/svg+xml" width=300 height=300></object>
                    <figcaption class='captionpdf'>Average + Tanh Attention</figcaption>
                    <figcaption class='captionpdf' id='resaveragetanh'></figcaption>
                </figure>
            </div>
            <div class="col" width="100%" height="100%">
                <figure class="figure">
                    <!-- <canvas id="pdfcnntanh"></canvas> -->
                    <object id="svgcnntanh" data="" type="image/svg+xml" width=300 height=300></object>
                    <figcaption class='captionpdf'>CNN + Tanh Attention</figcaption>
                    <figcaption class='captionpdf' id='rescnntanh'></figcaption>
                </figure>
            </div>
            <div class="col" width="100%" height="100%">
                <figure class="figure">
                    <!-- <canvas id="pdflstmtanh"></canvas> -->
                    <object id="svglstmtanh" data="" type="image/svg+xml" width=300 height=300></object>
                    <figcaption class='captionpdf'>LSTM + Tanh Attention</figcaption>
                    <figcaption class='captionpdf' id='reslstmtanh'></figcaption>
                </figure>
            </div>
        </div>
        <div class='row'>
            <div class="col" width="100%" height="100%">
                <figure class="figure">
                    <!-- <canvas id="pdfaveragedot"></canvas> -->
                    <object id="svgaveragedot" data="" type="image/svg+xml" width=300 height=300></object>
                    <figcaption class='captionpdf'>Average + Dot Attention</figcaption>
                    <figcaption class='captionpdf' id='resaveragedot'></figcaption>
                </figure>
            </div>
            <div class="col" width="100%" height="100%">
                <figure class="figure">
                    <!-- <canvas id="pdfcnndot"></canvas> -->
                    <object id="svgcnndot" data="" type="image/svg+xml" width=300 height=300></object>
                    <figcaption class='captionpdf'>CNN + Dot Attention</figcaption>
                    <figcaption class='captionpdf' id='rescnndot'></figcaption>
                </figure>
            </div>
            <div class="col" width="100%" height="100%">
                <figure class="figure">
                    <!-- <canvas id="pdflstmdot"></canvas> -->
                    <object id="svglstmdot" data="" type="image/svg+xml" width=300 height=300></object>
                    <figcaption class='captionpdf'>LSTM + Dot Attention</figcaption>
                    <figcaption class='captionpdf' id='reslstmdot'></figcaption>
                </figure>
            </div>
        </div>
        <div class='row'>
            <div class="col" width="100%" height="100%">
                <div id="caption_fig">

                </div>
            </div>
        </div>
    </div>
    <script type='text/javascript'>
        $(document).ready(function() {
            $('#submitform').click(function(){
                console.log('clicked');
                var dataset = $('#dataset').val();
                var experiment = $('#experiment').val();
                console.log(dataset);
                console.log(experiment);
                var attentions = ['tanh', 'dot'];
                var encoders = ['average', 'cnn', 'lstm'];

                for (attn in attentions) {
                    for (enc in encoders) {
                        var attention = attentions[attn];
                        var encoder = encoders[enc];
                        if (encoder == 'cnn') {
                            encoder = 'cnn(1,3,5,7)';
                        }

                        var url = '../graph_outputs/' + experiment + '/' + dataset + '+' + encoder + '+' + attention + '.svg';
                        $('#svg' + encoders[enc] + attentions[attn]).attr('data', url);

                        var json_url = '../graph_outputs/evaluate/' + dataset + '+' + encoder + '+' + attention + '.json';
                        var metric = $('#dataset :selected').parent('optgroup').first().attr('metric');
                        console.log(metric);
                        $.ajax({
                            url: json_url, 
                            context: {metric: metric, encname: encoders[enc], attnname: attentions[attn]},
                            success: function(data){

                                var acc = data[this.metric].toPrecision(3);
                                $('#res' + this.encname + this.attnname).text(this.metric + ': ' + acc);
                            }
                        });
                    }   
                }
            });
            $('#submitform').trigger('click');
        });
    </script>
</body>

</html>
